<template>
	<view>
		<view class="cu-list menu">
			<view class="cu-item" v-for="(item,index) in  history" :key="index">
				<view class="content padding-tb-sm">
					<view>
						<text class="text-blue margin-right-xs"></text>
						充值记录
					</view>
					<view class="text-gray text-sm">
						<text class="margin-right-xs"></text>
						{{item.recharge_time}}
					</view>
				</view>
				<view class="action"><text class="text-grey text-sm">{{item.recharge_monetary}}元</text></view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '@/api/index.js';
	//通过命名空间的方式映入
	import {
		createNamespacedHelpers
	} from 'vuex'
	//获取需要管理的方法
	const {
		mapState,
		mapActions,
		mapMutations
	} = createNamespacedHelpers('user')

	export default {
		data() {
			return {
				modalName: null,
				money: 500,
				history: []
			};
		},
		/**
		 * 计算属性
		 * @type {Object}
		 */
		computed: {
			...mapState(['userInfo']),
		},
		onLoad() {
			this.getHistory();
		},
		methods: {
			hideModal(e) {
				this.modalName = null;
			},
			getHistory() {
				console.log(this.userInfo);
				if (JSON.stringify(this.userInfo) == "{}") {
					uni.navigateTo({
						url: '/pages/login/login'
					});
					return;
				}
				let data = {
					"open_id": this.userInfo.openId
				}
				console.log("提交数据", data);
				api.benwei.get_history(data).then(response => {
					console.log("获取数据", response);
					this.history = response;
				});
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target;
			}
		}
	};
</script>

<style>
	.bw-help {
		padding-top: 30rpx;
	}
</style>
